package cn.com.connext.scrm.service;

import cn.com.connext.scrm.domain.master.UserAccessRecord;
import cn.com.connext.scrm.repository.master.UserAccessRecordRepository;
import cn.com.connext.scrm.web.rest.vm.BrowseVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 2 * @Author: shawn
 * 3 * @Date: 2019/10/29 6:54 下午
 * 4
 */
@Service
@Transactional
public class UserAccessRecordService extends BaseService{

    @Autowired
    private UserAccessRecordRepository userAccessRecordRepository;

    protected UserAccessRecordService(UserAccessRecordRepository userAccessRecordRepository) {
        super(userAccessRecordRepository);
        this.userAccessRecordRepository = userAccessRecordRepository;
    }

    public void browse(BrowseVM vm) {
        UserAccessRecord record = new UserAccessRecord();
        record.setOpenId(vm.getOpenId());
        record.setUnionId(vm.getUnionId());
        record.setUrl(vm.getUrl());
        record.setCreateTime(new Date());
        userAccessRecordRepository.save(record);
    }
}
